#include <irrlicht.h>
#include <iostream>

#include "CGUIIconFactory.h"

using namespace irr;
using namespace gui;

#pragma comment(lib, "Irrlicht.lib")

int main()
{
	// ask user for driver

	video::E_DRIVER_TYPE driverType;

	printf("Please select the driver you want for this example:\n"\
		" (a) Direct3D 9.0c\n (b) Direct3D 8.1\n (c) OpenGL 1.5\n"\
		" (d) Software Renderer\n (e) Burning's Software Renderer\n"\
		" (f) NullDevice\n (otherKey) exit\n\n");

	char i='a';
	std::cin >> i;

	switch(i)
	{
		case 'a': driverType = video::EDT_DIRECT3D9;break;
		case 'b': driverType = video::EDT_DIRECT3D8;break;
		case 'c': driverType = video::EDT_OPENGL;   break;
		case 'd': driverType = video::EDT_SOFTWARE; break;
		case 'e': driverType = video::EDT_BURNINGSVIDEO;break;
		case 'f': driverType = video::EDT_NULL;     break;
		default: return 1;
	}	


	IrrlichtDevice *device =createDevice(driverType, core::dimension2d<s32>(800, 600));
	video::IVideoDriver* driver = device->getVideoDriver();
	scene::ISceneManager* smgr = device->getSceneManager();
	gui::IGUIEnvironment *env = device->getGUIEnvironment();

	// create factory and add it to the environment

	CGUIIconFactory* factory = new CGUIIconFactory(env);
	env->registerGUIElementFactory(factory);

	// let's add an icon
	CGUIIcon* icon = factory->addIcon(core::position2di(110,110), 0, env->getSkin()->getSpriteBank(), L"Testing"); 

	// drop the factory and let the gui env look after it
	factory->drop();




	u32 time = device->getTimer()->getRealTime();

	while(device->run()) 
	{
		//device->sleep(100);

		if (device->isWindowActive())
		{
			driver->beginScene(true, true, video::SColor(0,200,200,200));
			smgr->drawAll();
			env->drawAll();
			driver->endScene();
		}
	}

	device->drop();
	
	return 0;
}


